<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" session="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <title>维修状况管理</title>

    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>

    <style type="text/css">
        .main h5 a {
            position: absolute;
            right: 20px;
            font-size: 14px;
            bottom: 0px;
            display: inline-block;
            padding: 5px;
        }

        .table_list tbody tr {
            height: 35px;
            text-align: center;
        }
    </style>
</head>
<body view="menu-item-4142">
<jsp:include page="../../top.jsp"></jsp:include>
<div class="right">
    <div class="wrapper">
        <div class="panel panel-default">
            <div class="panel-heading">
                <span><strong>查询条件</strong></span>

                <div class="ibox-tools">
                    <a class="collapse-link"> <i class="fa fa-chevron-down"></i></a>
                    <a class="collapse-link  d-n"> <i class="fa fa-chevron-up"></i></a>
                </div>
            </div>
            <div class="panel-body">
                <form class="form-horizontal">
                    <div class="form-group">
                      	<label class="selectlabe1 col-md-1 form-lable">维修工姓名：</label>
	                        <div class="col-md-3" >
	                            <input id="userName" name="userName" type="text" class="form-control"/>
	                        </div>
				         	<label class="col-md-1 form-lable" style="width:125px;">维修工手机号：</label>
	                        <div class="col-md-3" >
	                            <input id="userTel" name="userTel" type="text" class="form-control"/>
	                        </div>
	                        <div class="col-md-1 form-action">
                            <button class="btn btn-success form-control" id="query">查询</button>
	                        </div>
	                        <div class="col-md-1 form-action">
	                            <button class="btn btn-success form-control" id="resetForm">清空</button>
	                        </div>
                      </div>
                </form>
            </div>
        </div>
	    <div class="jqGrid_wrapper">
	        <div id="jqGrid_operation" class="jg-grid">
	            <h1>准备维修中</h1>
	            <div class="jqGrid_operation" id="action"></div>
	        </div>
	        <table id="jqGrid"></table>
	        <div id="jqGrid_paper"></div>
	    </div>
    </div>
</div>
<script>
    $(document).ready(
            function () {
				if("${ifdelete}" == "true"){
                    $("#action").append("<a id=\"del\"><i class=\"glyphicon glyphicon-trash\"></i>删除</a>");
                    $("#del").click(function () {
                        var sels = jQuery("#jqGrid").jqGrid('getGridParam', 'selarrrow');
                        if (sels == "") {
                            layer.alert("请选择要删除的维修记录", {
                                icon: 6,
                                closeBtn: false
                            });
                        } else {
                            layer.confirm('确认删除所选择的维修记录', function (index) {
                                $.post("${pageContext.request.contextPath}/admin/fix_delete.action", {
                                    "ids": sels.toString()
                                }, function (result) {
                                    result = eval("(" + result + ")");
                                    layer.alert(result.msg);
                                    refreshGrid();
                                });
                                layer.close(index);
                            });
                        }
                    });
				}
                               

                $.jgrid.defaults.styleUI = "Bootstrap";
                $("#jqGrid").jqGrid(
                        {
                            url: "${pageContext.request.contextPath}/admin/fix_fixerFixListPage.action?status=3&fixerid=${fixerid}",
                            mtype: 'POST',
  	                      datatype: "json",
  	                      height: 350,
  	                      autowidth: true,
  	                      shrinkToFit: true,
  	                      rowNum: 10,
  	                      rowList: [10, 20, 30],
  	                      colNames: ['序号','姓名','手机','服务介绍', /**'职能',**/'申请时间', '楼栋单元','房间号', '住户姓名', 
  	       	                      '住户手机',/**'维修类型',**/'回复住户','完成时间'],
  	                      colModel: [{
  	                          name: "SID",
  	                          index: "SID",
  	                          key: true,
  	                          hidden: true
  	                      },{
  	                          name: "FIXNAME",
  	                          index: "FIXNAME",
  	                          width: 80,
  	                      }, {
  	                          name: "FIXTEL",
  	                          index: "FIXTEL",
  	                          width: 90,
  	                      },{
                              name: 'INTRODUCTION',
                              index: 'INTRODUCTION',
                              width: 80
                          },
//                            {
//                               name: "FIXERTYPE",
//                               index: "FIXERTYPE",
//                               formatter: "select",
//                               editoptions: {value: "-1:;1:水电工;"},
//                               width: 80
//                           },
                          {
  	                          name: 'CTIME',
  	                          index: 'CTIME',
  	                          width: 90
  	                      },{
  	                          name: 'CBNAME',
  	                          index: 'CBNAME',
  	                          width: 80,
  	                      }, {
  	                          name: "ROOM",
  	                          index: "ROOM",
  	                          width: 80,
  	                      },{
  	                          name: "AUNAME",
  	                          index: "AUNAME",
  	                          width: 80,
  	                      }, {
  	                          name: "APPLYTEL",
  	                          index: "APPLYTEL",
  	                          width: 90,
  	                      },
//   	                      {
//   	                          name: "TYPE",
//   	                          index: "TYPE",
//   	                          width: 80,
//   	                          formatter: function (cellvalue, options, rawObject) {
//   		                          	if(cellvalue=='-1' || !cellvalue){
//   		                              	return '';
//   		                              }if (cellvalue == 1){
//   		                              	return "<a onclick='applyDetail("+rawObject.SID+")'>水电维修</a>";
//   		                              }else{
//   		                              	return '';
//   		                              }
//   		                          }
//   	                      },
  	                        {
  	                          name: "STATUS",
  	                          index: "STATUS",
  	                          width: 80,
  	                          formatter: function (cellvalue, options, rawObject) {
  		                          	if(cellvalue=='-1' || !cellvalue){
  		                              	return '';
  		                              }else if (cellvalue == 1){
  										return "待回复";
  		                              }else if (cellvalue == 2 && !rawObject.FIXNAME){
  		                              	return "<font style='color: #908e8e;'>待回复</font>";
  		                              }else{
  		                              	return "<a onclick='replyDetail("+rawObject.SID+")'>已回复</a>";
  		                              }
  		                          }
  	                          
  	                          
  	                      },{
  	                          name: "FINISHTIME",
  	                          index: "FINISHTIME",
  	                          width: 90,
  	                      }],
  	                      sortname: 't.sid',
  	                      sortorder:'desc',
  	                      rownumbers: true,
  	                      jsonReader: {
  	                          root: 'rows',
  	                          page: "page",
  	                          total: 'total',
  	                          records: "records",
  	                          repeatitems: false
  	                      },
  	                      pager: "#jqGrid_paper",
  	                      viewrecords: true,
  	                      multiselect: true,
  	                      hidegrid: false,
  	                      loadComplete: function(){
  	                    		var re_records = Number($("#jqGrid").getGridParam('records'));
  	                    		var page = Number($("#jqGrid").getGridParam('page'));
  	                    		var rows=Number($("#jqGrid").getGridParam('rowNum'));
  	                    		var num = re_records-(page-1)*rows;
  	                    		if(num < rows)
  	                    		{
  	                    			for(var i=num;i<rows;i++){
  	                    				$("#jqGrid").jqGrid("addRowData",(i+1),
  	                            				{ "SID":"","TYPE":"-1","STATUS":"-1"}
  	                    				,"");
  	                    			}
  	                    			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
  	                    		}
  	                    	}
  	                  });
                <!--查询-->
                jQuery("#query").click(query);
                jQuery("#resetForm").click(resetForm);
            });

    
    
    <!--刷新jqGrid表格数据-->
    function refreshGrid() {
        $("#jqGrid").trigger("reloadGrid");
    }
    function resetForm() {
        location.reload();
        return false;
    }
    function query() {
        var userName = $("#userName").val();
        var userTel = $("#userTel").val();
        $("#jqGrid").jqGrid('setGridParam', {
            url: "${pageContext.request.contextPath}/admin/fix_fixerFixListPage.action",
            postData: {
                'status':3,
                'fixerid':'${fixerid}',
            	'userName':userName,
                'userTel': userTel
            }, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入*/
        return false;
    }
    function replyDetail(sid){
    	layer.open({
            type: 2,
            title: '<strong>回复</strong>',
            shadeClose: true, //点击遮罩关闭层
            area: ['400px', '280px'],
            content: '${pageContext.request.contextPath}/admin/fix_replyDetailView.action?sid='
            + sid,
            btn: ['确定'],
            yes: function (index, layero) {
                  layer.closeAll();
             }
        });
    }
    function applyDetail(sid){
    	layer.open({
            type: 2,
            title: '<strong>维修详情</strong>',
            shadeClose: true, //点击遮罩关闭层
            area: ['500px', '380px'],
            content: '${pageContext.request.contextPath}/admin/fix_applyDetailView.action?sid='
            + sid,
            btn: ['确定'],
            yes: function (index, layero) {
                  layer.closeAll();
             }
        });
    }
</script>
</body>
</html>
